@echo off

set databaseName=%1
set userName=%2
set password=%3

set usage=Usage: setupdb databaseName username password. eg. setupdb arch arch arch
if "%databaseName%" == "" (
    echo %usage%
    exit /B 1
)
if "%userName%" == "" (
    echo %usage%
    exit /B 1
)
if "%password%" == "" (
    echo %usage%
    exit /B 1
)

set errorlevel=
db2 connect to %databaseName% user %userName% using %password%
if not "%errorlevel%" == "0" (
    echo invalid database name, user name or password
    exit /B 2
)

db2 -tvf dml.user.admin.sql -z setupdb-user.admin.log

db2 terminate
